<template>
  <div>
    <header class="site-header jumbotron">
      <div class="container">
        <div class="row">
          <div class="col-xs-12">
            <h1>请发表对LOL的评论</h1>
          </div>
        </div>
      </div>
    </header>
    <div class="container">
      <Add :addComment="addComment"/>
      <List :comments="comments" :deleteComment="deleteComment"/>
    </div>
  </div>
</template>

<script>
  import Add from './components/Add'
  import List from './components/List'

  export default {
    components: {
      Add,
      List
    },
    data () {
      return {
        comments: [
          {
            name: '亚索',
            content: '面对疾风吧'
          },
          {
            name: '盲僧',
            content: '我用双手成就你的梦想'
          },
          {
            name: '库奇',
            content: '大部分人都会打飞机,这对飞机来说很不公平'
          }
        ]
      }
    },
    methods: {
      // 添加评论
      addComment (comment) {
        this.comments.unshift(comment)
      },
      // 删除指定下标的评论
      deleteComment (index) {
        this.comments.splice(index, 1)
      }
    }
  }
</script>

<style>

</style>
